import router from './router/'
import store from './store'
import { validatenull } from './utils/validate'
import { Toast } from 'vant'
router.beforeEach((to, from, next) => {
    document.title = to.name;
    const token = store.state.token;
    const user = store.state.user;
    if (validatenull(token) || validatenull(user)) {
        if (validatenull(to.query.token)) {
            // if (to.fullPath == "/login") {
            //     next()
            // } else {
            //     next('/login')
            // }
            next()
        }
        // store.commit('setToken', to.query.token);

    } else {
        store.dispatch('getUser')
            .then(() => {
                next();

            })
    }

})